﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class UserL : WebPageBase
{

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            HiddenFieldUserId.Value = base.UserSystem.Id.ToString();

            switch (base.UserSystem.RoleId.Value)
            {
                case 2: GridViewUser.Visible = false; break;
                case 3: GridViewUser.DataSourceID = "LinqDataSourceUserLider"; break;
                default: GridViewUser.DataSourceID = "LinqDataSourceUser"; break;
            }
            GridViewUser.DataBind();
        }
    }

    protected void ButtonNewRegister_Click(object sender, EventArgs e)
    {
        Response.Redirect("Register.aspx");
    }

    protected void GridViewUser_DataBound(object sender, EventArgs e)
    {
        for (int i = 0; i < GridViewUser.Rows.Count; i++)
        {
            Role role = db.Roles.First(u => u.RoleId.Equals(GridViewUser.Rows[i].Cells[2].Text));
            GridViewUser.Rows[i].Cells[2].Text = role.Name;
        }
    }
}
